load("//bazel:skia_rules.bzl", "skia_cc_library", "skia_filegroup")

package(
    default_applicable_licenses = ["//:license"],
)

licenses(["notice"])

# In own group for export to .gni
skia_filegroup(
    name = "vma_srcs",
    srcs = [
        "VulkanAMDMemoryAllocator.cpp",
        "VulkanAMDMemoryAllocator.h",
        "VulkanMemoryAllocatorPriv.h",
    ],
)

skia_cc_library(
    name = "vulkanmemoryallocator",
    srcs = [
        "VulkanAMDMemoryAllocator.cpp",
        "VulkanAMDMemoryAllocator.h",
        "VulkanMemoryAllocatorWrapper.cpp",
    ],
    hdrs = [
        "VulkanMemoryAllocatorPriv.h",
    ],
    copts = [
        # Because `copts` options don't propagate up the stack, some static errors in
        # `vk_mem_alloc.h` need to be suppressed in the BUILD rule which includes the library.
        #
        # https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/issues/298
        "-Wno-unused-variable",
        # https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/issues/299
        "-Wno-implicit-fallthrough",
    ],
    implementation_deps = [
        "//include/third_party/vulkan",
    ],
    local_defines = ["SK_USE_INTERNAL_VULKAN_HEADERS"],
    textual_hdrs = [
        "VulkanMemoryAllocatorWrapper.h",
    ],
    visibility = [
        # We explicitly do not want to expose this as a public module because we cannot
        # really have a one-size-fits-all allocator nor one that is runtime-configurable.
        "//tools:__subpackages__",
        "//src/gpu/vk:__pkg__",
    ],
    deps = [
        "//:core",
        "//src/base",
        "//src/gpu/vk",
        "@vulkanmemoryallocator//:hdrs",
    ],
)

# TODO(kjlubick) remove this when SK_USE_VMA is deleted
skia_cc_library(
    name = "vulkanmemoryallocator_priv",
    hdrs = [
        "VulkanAMDMemoryAllocator.h",
        "VulkanMemoryAllocatorPriv.h",
    ],
    visibility = [
        "//src/gpu/ganesh/vk:__pkg__",  # TODO(kjlubick) remove when this is not built in
    ],
    deps = [":vulkanmemoryallocator"],
)
